package com.blockchainenergy.info.market.impl;

import com.blockchainenergy.info.market.InfoMarket;
import com.blockchainenergy.info.market.InfoMarketService;
import com.blockchainenergy.info.market.dao.InfoMarketDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @descriptions:
 */
@Service
@Transactional
public class InfoMarketServiceImpl implements InfoMarketService {
    @Resource
    InfoMarketDao infoMarketDao;

    @Override
    public void refreshMarketInfo(Integer timeSlot) {
        Integer t = infoMarketDao.getTradingVolumesByTime(timeSlot);
        Double ma = infoMarketDao.getMaxPriceByTime(timeSlot);
        Double mi = infoMarketDao.getMinPriceByTime(timeSlot);
        Double av = infoMarketDao.getAverageByTime(timeSlot);
        if (t == null || ma == null || mi == null || av == null) {
            return;
        }
        InfoMarket.add(timeSlot, t, ma, mi, av);
    }
}
